package manager.universe;

import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

import rendering.CameraFreeFlight;

/**
 * L'univers est le conteneur des objets, il ce block a un seul thread quand on le get via le singleton.
 * Il devrait toujours et seulement etre utilisé dans la methode lockedRun d'un UniverseManager
 * 
 * @author Louis
 *
 */
public class Universe {
	
	private static Universe universe;
	private static Lock lock = new ReentrantLock();
	
	private CameraFreeFlight cameraFreeFlight;
	
	private double[] triangle; // Le triangle, exemple qui disparaitra apres.
	
	public static  Universe getUniverse(){
		lock.lock();
		if(universe == null)
			universe = new Universe();
		return universe;
	}
	
	private Universe(){
		cameraFreeFlight = new CameraFreeFlight();
		triangle = new double[]{0.0,0.0,0.0};
	}
	
	public double[] getTriangle(){
		return triangle;
	}
	
	public CameraFreeFlight getCamera(){
		return cameraFreeFlight;
	}
	
	public static void release(){
		lock.unlock();
	}
}
